import { BuiltInFunc } from "./com/BuiltInFunc";
export class StringNode extends BuiltInFunc {
    constructor(name?: string) {
        super(name ? name : 'String')
        this.edit.out = false
        this.canReference = true
        this.funcName = 'replace';
        this.bgColor = '#93624d'
        this.addAttribute({
            name: "type",
            value: "replace",
            type: 'string',
            options: ['replace', 'split','concat','find','match']
        })
        this.addAttribute({
            name: "search",
            value: '',
            type: 'string',
            options: undefined
        })
        this.addInput({ key: 'origin' })
        this.addInput({ key: 'new' })
        this.addOutput({ key: 'output' })
        this.onAttibuteChange = this.onAttrChange.bind(this)
        this.refresh()
    }

    private onAttrChange(attr: NodeAttribute) {
        if (attr.name === 'type') {
            this.funcName = attr.value
        }
        this.createAttributes()
    }
    public get className(){
        return 'String'
    }
}